
public class TestDate {
    public int year;
    public int month;
    public int day;
                       //this代表当前对象的引用
    public void setDate(TestDate this,int year,int month,int day){
        //局部变量优先
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public void printDate(){
        System.out.println(this.year+"-"+this.month+"-"+this.day);
    }

    public void func() {
        this.printDate();
    }

    public static void main1(String[] args) {
        TestDate testDate = new TestDate();
        testDate.setDate(2023,10,17);
        testDate.printDate();
    }

    //this.成员变量
    //this.成员方法
    //this()访问构造方法
    public static void main(String[] args) {
        TestDate testDate1 = new TestDate();
        TestDate testDate2 = new TestDate();
        TestDate testDate3 = new TestDate();

        testDate1.setDate(2023,10,17);
        testDate2.setDate(2024,10,17);
        testDate3.setDate(2025,10,17);

        testDate1.printDate();
        testDate2.printDate();
        testDate3.printDate();
    }
}